home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / MorphOS / Epic4_mos / share / epic / script / ip-to-int < prev    next >
Encoding:
Text File  |  2002-10-28  |  479 b   |  23 lines

  1. : {
  2.     This converts an ip address (which you provide)
  3.     into a 32 bit internet address, ala what DCC uses.
  4.     One small problem -- epic does math with 'long's and
  5.     not 'unsigned long's and so ip addresses above 128.*
  6.     result in negative values.  How to fix this is left
  7.     as an exercise for the reader.
  8.  
  9.     Written in November, 2000
  10. }
  11.  
  12. alias ip_to_int (ip, void)
  13. {
  14.     @ :ip_list = split(. $ip)
  15.     @ :ip32 = 0
  16.     for xx in ($ip_list) {
  17.         @ ip32 = (ip32 << 8) + xx
  18.     }
  19.     return $ip32
  20. }
  21.  
  22. #hop'y2k
  23.